package cn.edu.zju.qsc.rouchseg.tools;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

public class FileTool {
	/** 读字典文件 
	 * @return */
	public static List<String> readDicFile(String filename) 
					throws FileNotFoundException, UnsupportedEncodingException {
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
//		InputStream is = new FileInputStream(filename);
		BufferedReader in = new BufferedReader(new InputStreamReader(is,"utf-8"));

		String s;
		List<String> words = new ArrayList<String>();
		try {
			while ((s = in.readLine()) != null) {
				words.add(s);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return words;
	} //end function readDicFile
}
